#define _CRT_NO_SECURE_WARNINGS
#include <stdio.h>
int main() {
	int a, b, temp;
	int i = scanf("%d %d", &a, &b);
	if (a < b)
	{
		temp = a;
		a = b;
		b = temp;
	}
	while (b != 0)
	{
		temp = a % b;
		a = b;
		b = temp;
	}
	printf("%d\n", a);
	return 0;
}